<template>
	<view style="margin-left: 15px;margin-right: 15px;">
		<u-form :model="hiddenVo" ref="uForm" :rules="rules">
			<u-form-item label="标题" labelWidth="70px">
				<u-input v-model="hiddenVo.name" placeholder="请输入标题" :border="true" />
			</u-form-item>
			<u-form-item label="地点" labelWidth="70px">
				<u-input v-model="hiddenVo.place" placeholder="请输入地点信息" :border="true" />
			</u-form-item>
			<u-form-item label="描述" labelWidth="70px">
				<u-input v-model="hiddenVo.description" placeholder="描述内容" type="textarea" :border="true" />
			</u-form-item>
			<!-- 			//图片 -->
			<u-form-item label="隐患类型" labelWidth="70px">
				<u-input v-model="type" type="select" placeholder="请选择" :border="true" @click="hiddenTypeShow = true" />
				<u-select v-model="hiddenTypeShow" mode="single-column" :list="hiddenTypes"
						  @confirm="hiddenTypeConfirm">
				</u-select>
			</u-form-item>
			<u-form-item label="上报时间" labelWidth="70px">
				<u-input v-model="hiddenVo.reportDate" placeholder="选择时间"  :disabled="true" :border="true" @click="timeShow = true" />
				<u-calendar v-model="timeShow" mode="date" @change="timeChange" :min-date="getDate()"  :max-date="getDate()"></u-calendar>
			</u-form-item>
			<u-form-item label="上报人" labelWidth="70px">
				<u-input v-model="hiddenVo.reportPeople" placeholder="请输入您的姓名" :border="true" />

			</u-form-item>
			<u-form-item label="联系方式" labelWidth="70px">
				<u-input v-model="hiddenVo.phone" placeholder="请输入您的联系方式" :border="true" />

			</u-form-item>
			<u-button :custom-style="customStyle" type="primary" @click="submit">提交</u-button>
		</u-form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				rules:{

				},
				hiddenTypeShow:false,
				timeShow:false,
				customStyle: {
					marginTop: "100px",
				},
				hiddenVo:{
					id:0,
					name:"",
					place:"",
					description:"",
					reportDate:"",
					hiddenTroubleTypeId:"",
					reportPeople:"",
					phone:"",
				},
				hidden:{
					id:0,
					name:"",
					place:"",
					description:"",
					hiddenType:{
						id:0,
						name:""
					},
					reportDate:"",
					reportPeople:"",
					phone:""
				},
				type:"",
				hiddenType:{
					id:0,
					name:""
				},
				hiddenTypes:[],

			}
		},
		methods:{
			submit(){
				console.log(this.hiddenVo)
			},
			getDate() {
				let dateNow = new Date();
				return dateNow.getFullYear() + "-" + (dateNow.getMonth() + 1) + "-" + dateNow.getDate()
			},
			hiddenTypeConfirm(data) {
				this.hiddenVo.hiddenTroubleTypeId = data[0].value;
				this.type = data[0].label;
				console.log(this.hiddenVo)
			},
			timeChange(date){
				this.hiddenVo.reportDate=date.result
			},
			getTypes(){
				this.$axios.post("/api/xjh/hidden/getAllType").then(r=>{
					if(r.data.code==200){
						// console.log(r.data.data)
						//this.hiddenTypes=r.data.data
						for (let s of r.data.data) {
							let s1={
								value:s.id,
								label:s.name
							}
							console.log(s1)
							this.hiddenTypes.push(s1);
						}
						console.log(this.hiddenTypes)
					}
				})
			}
		},
		created(){
			this.getTypes()
		}
	}
</script>

<style>
</style>